package com.qiaofang.applet.service.member.service.mapstruct;

import com.qiaofang.applet.service.member.domain.MemberBrowse;
import com.qiaofang.applet.service.property.service.dto.VisitorRecordsListDto;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;

import java.util.ArrayList;
import java.util.List;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MemberBrowseMapper {

    default List<VisitorRecordsListDto> domainToListDto(List<MemberBrowse> list){
        if ( list == null ) {
            return null;
        }

        List<VisitorRecordsListDto> list1 = new ArrayList<VisitorRecordsListDto>( list.size() );
        for ( MemberBrowse memberBrowse : list ) {
            list1.add( memberBrowseToVisitorRecordsListDto( memberBrowse ) );
        }

        return list1;
    }

    default VisitorRecordsListDto memberBrowseToVisitorRecordsListDto(MemberBrowse memberBrowse) {
        if ( memberBrowse == null ) {
            return null;
        }

        VisitorRecordsListDto visitorRecordsListDto = new VisitorRecordsListDto();

        visitorRecordsListDto.setMemberId( memberBrowse.getMemberId() );
        visitorRecordsListDto.setMemberName( memberBrowse.getMemberName() );
        visitorRecordsListDto.setCount( memberBrowse.getCount() );
        visitorRecordsListDto.setEstateName( memberBrowse.getEstateName() );
        visitorRecordsListDto.setHouseType( memberBrowse.getHouseType() );
        visitorRecordsListDto.setMainImageUrl( memberBrowse.getMainImageUrl() );
        if ( memberBrowse.getSquare() != null ) {
            visitorRecordsListDto.setSquare( memberBrowse.getSquare().toString());
        }
        visitorRecordsListDto.setRead( memberBrowse.getRead() );
        visitorRecordsListDto.setCreateTime(memberBrowse.getCreateTime());
        return visitorRecordsListDto;
    }





}
